//index.js
//获取应用实例
var url = "http://www.weiapp.cy/index.php?s=/Home/Cms/getList";
var p=1;


// 请求数据
var loadMore = function (that) {
  wx.request({
    url: url,
    data: {
     p:p
    },
    success: function (res) {
      var list = that.data.list;
      that.setData({
        list:list.concat(res.data)
      });
      p++
    }
  });
}
Page({
  data: {
    list: [],
    scrollHeight: 0
  },
  //事件处理函数
  bindViewTap: function (event) {
    wx.navigateTo({
      url: '../detail/detail?id='+ event.currentTarget.dataset.name
    })
  },
  onLoad: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          scrollHeight: res.windowHeight
        });
      }
    });
    loadMore(that);
  },
  onPullDownRefresh: function () {
    var that = this;
    wx.stopPullDownRefresh()
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 1000
    })
    loadMore(that);
  }
})
